export function getColumns() {
  return [
    {
      prop: "name",
      label: "姓名",
      formItemProps: {
        rules: [
          {
            required: true,
            message: "此项为必填项",
          },
        ],
        compProps: {},
      },
    },
    {
      prop: "sex",
      label: "性别",
      formItemProps: {
        component: "select",
        compProps: {},
        dataSource: [
          {
            label: "男",
            value: 1,
          },
          {
            label: "女",
            value: 0,
          },
        ],
      },
      slotFn: ({ row }) => ["女", "男"][row.sex],
    },
    {
      prop: "clothes",
      label: "衣服",
      formItemProps: {
        component: "select",
        compProps: {},
        watch: {
          // 表单联动控制
          target: ["sex"],
          callback: ({
            targetValue,
            currentItem,
            modelValue,
            targetItem,
            columns,
          }) => {
            console.log("表单联动控制", {
              targetValue,
              currentItem,
              targetItem,
              modelValue,
              columns,
            });
            modelValue["clothes"] = undefined;
            if (targetValue === 1) {
              // 男
              currentItem.dataSource = [
                {
                  label: "西装",
                  value: 1,
                },
                {
                  label: "领带",
                  value: 0,
                },
              ];
            } else if (targetValue === 0) {
              currentItem.dataSource = [
                {
                  label: "裙子",
                  value: 1,
                },
                {
                  label: "包包",
                  value: 0,
                },
              ];
            } else {
              currentItem.dataSource = [];
            }
          },
        },
        dataSource: [],
      },
      slotFn: ({ row }) => <div>{row.sex === 0 ? "女" : "男"}</div>,
    },
    {
      label: "酒店点类型",
      prop: "hotelType",
      width: 240,
      dictType: "hotel_type", // 指定字典类型
      formItemProps: {
        component: "select",
        labelWidth: "110px",
      },
    },
    {
      prop: "status",
      label: "状态",
      slotFn: ({ row }) => (
        <el-tag type={row.status === 0 ? "danger" : "success"}>
          {row.status === 0 ? "禁用" : "启用"}
        </el-tag>
      ),
      formItemProps: {
        component: "select",
        request: () => {
          return new Promise((resolve) => {
            setTimeout(() => {
              const data = [
                {
                  label: "禁用",
                  value: 0,
                },
                {
                  label: "启用",
                  value: 1,
                },
              ];
              resolve(data);
            }, 1000);
          });
        },
      },
    },
    {
      prop: "date",
      label: "日期",
      formItemProps: {
        component: "cascader",
        compProps: {
          options: [
            {
              value: "zhinan",
              label: "指南",
              children: [
                {
                  value: "shejiyuanze",
                  label: "设计原则",
                  children: [
                    {
                      value: "yizhi",
                      label: "一致",
                    },
                    {
                      value: "fankui",
                      label: "反馈",
                    },
                    {
                      value: "xiaolv",
                      label: "效率",
                    },
                    {
                      value: "kekong",
                      label: "可控",
                    },
                  ],
                },
              ],
            },
          ],
        },
      },
    },
    {
      label: "操作",
      fixed: "right",
      width: 140,
      slotFn: ({ row }) => (
        <div>
          <el-button onclick={() => this.editRow(row)} type="text">
            编辑
          </el-button>
          <el-popconfirm
            title="这是一段内容确定删除吗？"
            onconfirm={() => this.deleteRow(row)}
          >
            <el-button type="text" slot="reference">
              删除
            </el-button>
          </el-popconfirm>
        </div>
      ),
    },
  ];
}
